<?php
/**
 * 视频控制器
 * Created		: 2012-10-09
 * Modified		: 2012-10-09
 * @link		: http://www.01pet.com
 * @copyright	: (C) 2012 01pet.com 
 * @author		: Joseph Chen (chenliq@gmail.com)
 */
class Controller_Video extends Controller
{
	/**
	 * 视频表
	 * @var string
	 */
	public $tbl = 'videos';
	
	/**
	 * 控制器载入后执行
	 */
	public function initialize()
	{
	}
	
	/**
	 * 视频列表
	 * @see Controller::index()
	 */
	public function index() 
	{
		// 视频列表
		$mo = new Model_Video();
		$params = array(
			'order'	=> 'post_time desc',
			'limit'	=> 30,
		);
		$videoList = $mo->getList();
		
	}
	
	/**
	 * 视频详细信息页
	 */
	public function view()
	{
		if (empty($_GET['id']) || !ctype_digit($_GET['id']))
		{
			$this->failure('video_not_exist');
		}

		$mo = new Model_Video();
		$this->detail = $mo->read($_GET['id']);
	}
	
	/**
	 * 视频作者列表页
	 */
	public function ownerList()
	{
		if (empty($_GET['id']) || !ctype_digit($_GET['id']))
		{
			$this->failure('video_not_exist');
		}

		$mo = new Model('video_owner');
		$mo->pageSize = 30;
		$options = array(
		);
		$this->detail = $mo->select($options);
	}
	
	/**
	 * 视频作者信息页
	 */
	public function ownerView()
	{
		if (empty($_GET['id']) || !ctype_digit($_GET['id']))
		{
			$this->failure('video_not_exist');
		}

		$mo = new Model('video_owner');
		$this->detail = $mo->read($_GET['id']);
	}
	
	/**
	 * 视频来源列表页
	 */
	public function fromList()
	{
		if (empty($_GET['id']) || !ctype_digit($_GET['id']))
		{
			$this->failure('video_not_exist');
		}

		$mo = new Model('video_from');
		$mo->pageSize = 30;
		$options = array(
		);
		$this->detail = $mo->select($options);
	}
	
	/**
	 * 视频来源信息页
	 */
	public function fromView()
	{
		if (empty($_GET['id']) || !ctype_digit($_GET['id']))
		{
			$this->failure('video_not_exist');
		}

		$mo = new Model('video_from');
		$this->detail = $mo->read($_GET['id']);
	}
	
	/**
	 * 保存视频信息
	 */
	public function save()
	{
		$mo = new Model_Video();
		$mo->save($_POST);
	}
	
	/**
	 * 保存视频所有人（解说，机构等）信息
	 */
	public function saveOwner()
	{
		$mo = new Model('video_owner');
		$mo->save($_POST);
	}
	
	/**
	 * 保存视频来源
	 */
	public function saveFrom()
	{
		$mo = new Model('video_from');
		$mo->save($_POST);
	}
}